package com.tencreat.service.pt.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.pt.MallPtUserIncomeRecord;
import com.tencreat.mapper.pt.MallPtUserIncomeRecordMapper;
import com.tencreat.service.pt.IMallPtUserIncomeRecordService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 拼团收益记录Service业务层处理
 *
 * @author tencreat
 * @date 2021-11-27
 */
@Service
public class MallPtUserIncomeRecordServiceImpl extends ServiceImpl<MallPtUserIncomeRecordMapper, MallPtUserIncomeRecord> implements IMallPtUserIncomeRecordService {


    /**
     * 查询拼团收益记录
     *
     * @param id 拼团收益记录ID
     * @return 拼团收益记录
     */
    @Override
    public MallPtUserIncomeRecord selectMallPtUserIncomeRecordById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询拼团收益记录列表
     *
     * @param mallPtUserIncomeRecord 拼团收益记录
     * @return 拼团收益记录
     */
    @Override
    public List<MallPtUserIncomeRecord> selectMallPtUserIncomeRecordList(MallPtUserIncomeRecord mallPtUserIncomeRecord) {
        return baseMapper.selectList(Wrappers.query(mallPtUserIncomeRecord));
    }

    /**
     * 新增拼团收益记录
     *
     * @param mallPtUserIncomeRecord 拼团收益记录
     * @return 结果
     */
    @Override
    public int insertMallPtUserIncomeRecord(MallPtUserIncomeRecord mallPtUserIncomeRecord) {
        mallPtUserIncomeRecord.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallPtUserIncomeRecord);
    }

    /**
     * 修改拼团收益记录
     *
     * @param mallPtUserIncomeRecord 拼团收益记录
     * @return 结果
     */
    @Override
    public int updateMallPtUserIncomeRecord(MallPtUserIncomeRecord mallPtUserIncomeRecord) {
        return baseMapper.updateById(mallPtUserIncomeRecord);
    }

    /**
     * 批量删除拼团收益记录
     *
     * @param ids 需要删除的拼团收益记录ID
     * @return 结果
     */
    @Override
    public int deleteMallPtUserIncomeRecordByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除拼团收益记录信息
     *
     * @param id 拼团收益记录ID
     * @return 结果
     */
    @Override
    public int deleteMallPtUserIncomeRecordById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
